package com.lanju.dao;

import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.lanju.entity.Contract;
import com.lanju.entity.ZukeContract;
@Repository
public class ContractJobDao {
	
    @PersistenceContext(unitName = "financialmarketingUnit")
    private EntityManager entityManager;
    
    @Autowired
   	SessionFactory sessionFactory;
    
	public List<Contract> getContractJob(Map<String,Object> map) {
		try {
			StringBuffer sql = new StringBuffer(); 
			sql.append(" FROM Contract c WHERE contractEndTime='"+map.get("contractEndTime").toString()+"'");
			Query query = entityManager.createQuery(sql.toString());
			return query.getResultList();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public List<ZukeContract> getZuKeContractJob(Map<String,Object> map) {
		try {
			StringBuffer sql = new StringBuffer(); 
			sql.append(" FROM ZukeContract c WHERE renter_end_time='"+map.get("contractEndTime").toString()+"'");
			Query query = entityManager.createQuery(sql.toString());
			return query.getResultList();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
